package nbcp.filter

import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.classic.turbo.TurboFilter
import ch.qos.logback.core.filter.Filter
import ch.qos.logback.core.spi.FilterReply
import org.slf4j.Marker
import nbcp.base.extend.AsString
import nbcp.base.extend.LogScope
import nbcp.base.extend.scopes
import nbcp.base.extend.using
import nbcp.base.utils.SpringUtil
import nbcp.web.HttpContext
import java.net.Inet4Address
import java.time.Duration
import java.time.LocalDateTime
import java.util.*
import kotlin.collections.LinkedHashMap

class MyLogBackFilter : Filter<ILoggingEvent>() {
    override fun decide(event: ILoggingEvent?): FilterReply {
        if( scopes.contains(LogScope.NoLog) ||  scopes.contains(LogScope.TaskLog)){
            return FilterReply.DENY
        }

        if (event == null || event.level == null || SpringUtil.isInited == false) {
            return FilterReply.NEUTRAL
        }
        if (scopes.contains(LogScope.NoInfo)  && (event.level.levelInt <= Level.INFO_INT)) {
            return FilterReply.DENY
        }

        return FilterReply.NEUTRAL
    }
}